﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Surface.Presentation.Controls;

namespace LetsGoToSchool
{
    /// <summary>
    /// Interaction logic for SongSelection.xaml
    /// </summary>
    public partial class SongSelection : UserControl
    {
        private MusicGame _main;

        /// <summary>

        ///Default Constructor
        /// </summary>
        /// 
        public SongSelection()
        {
            InitializeComponent();

            //list all of the songs and free play in the song menu 

            SurfaceListBoxItem listItem1 = new SurfaceListBoxItem();
            listItem1.Content = "Free Play";
            listItem1.Foreground = Brushes.DarkSlateBlue;
            listItem1.Background = Brushes.BlanchedAlmond;
            _songList.Items.Add(listItem1);
            _songList.SelectedItem = listItem1;

            SurfaceListBoxItem listItem2 = new SurfaceListBoxItem();
            listItem2.Content = "Ode To Joy";
            listItem2.Foreground = Brushes.DarkSlateBlue;
            listItem2.Background = Brushes.BlanchedAlmond;
            _songList.Items.Add(listItem2);

            SurfaceListBoxItem listItem3 = new SurfaceListBoxItem();
            listItem3.Content = "Mary Had A Little Lamb";
            listItem3.Foreground = Brushes.DarkSlateBlue;
            listItem3.Background = Brushes.BlanchedAlmond;
            _songList.Items.Add(listItem3);

            SurfaceListBoxItem listItem4 = new SurfaceListBoxItem();
            listItem4.Content = "Twinkle Twinkle Little Star";
            listItem4.Foreground = Brushes.DarkSlateBlue;
            listItem4.Background = Brushes.BlanchedAlmond;
            _songList.Items.Add(listItem4);

            foreach (SurfaceListBoxItem item in _songList.Items)
            {
                item.FontSize = 36;
                item.FontWeight = FontWeights.Bold;
            }

        }

        /// <summary>
        /// Event handler for when the user presses GO in the song selection menu.
        /// This starts the game by calling start game on the music game.
        /// </summary>
        /// 
        private void _startButton_Click(object sender, RoutedEventArgs e)
        {
            this.Visibility = Visibility.Hidden;
            string song = (_songList.SelectedItem as SurfaceListBoxItem).Content.ToString();
            if (song.Equals("Free Play"))
            {
                _main.startGame();
            }
            else
            {
                _main.startGame(song);
            }
            

        }

        //This is a mutator to set the MusicGAme for this song selection.
        public void setMain(MusicGame game) 
        {
            _main = game;
        }

        /// <summary>
        /// Event handler for the quit button.
        /// It closes the Music Game.
        /// </summary>
        /// 
        private void _quitButton_Click(object sender, RoutedEventArgs e)
        {
            _main.Close();
        }
    }
}
